<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://www.myfirefly.cn/tag/auth" prefix="auth"%>
<script type="text/javascript">
$(document).ready(function(){
	var url = 'spfTradeContractWebimage/imglist.do?contractId=${contractId}';
	var successCallBack = function(result){
		var html = "";
		html += '<div style="top:0px;">'
		<auth:has funcId="spfTradeContractWebimage" action="/spfTradeContractWebimage/uploadIndex.do">
		<c:if test='${noupdate=="false"}'>
		html += '<button type="button" onclick="openContractAddImagesAll(${contractId});" class="btn btn-default" style="margin-left:5px;"><i class="fa  fa-plus"></i> 添加文件</button>';
		</c:if>
		</auth:has>
		html += '</div>';
		html += '<div style="height:100%;overflow-y: auto;"><div class="attachment">';
		html += '<div class="attachment_list" id="contract_attachment">';
		if(result.data && result.data.length > 0){
			$.each(result.data, function(key, val) {     
				html+='<div class="attachment_box">';
				html+='<a href="javascript:void(0);"  onclick="atlas(this)">';
				html+='<div class="attachment_img">';
				html+='<img src='+val.imgUrl+'>';
				html+='</div>';
				html+='</a>';
				<auth:has funcId="spfTradeContractWebimage" action="/spfTradeContractWebimage/del.do">
				<c:if test='${noupdate=="false"}'>
				html+='<a href="javascript:void(0);" onclick="delContractAttachById('+val.id+',this);" class="btn btn-red delete"><i class="fa fa-remove"></i>删除</a>';
				</c:if>
				</auth:has>
				html+='</div>';
			});
		}
		html+='</div></div></div>';
		$("#contractFileForm_div").html(html);
	}
	myAjax(url,	"", true,successCallBack,null);
});

function openContractAddImagesAll(contractId) {
	$('#edit-spfTradeContractWebimageRecord-dialog').dialog({
		id:'edit-spfTradeContractWebimageRecord-dialog',
		url:'spfTradeContractWebimage/uploadIndex.do?contractId='+contractId,
		maxable: false,
		mask: true,
		width: 950,
		height: 680,
		onLoad: function($dialog){
			var $cancel = $dialog.find('.cancel');
			$cancel.click(function(){
				$dialog.dialog('close', 'edit-spfTradeContractWebimageRecord-dialog');
			});
		},
		
		title:'网签合同管理 - 上传'});
}

function delContractAttachById(id, _this) {
	var _html = '确定删除文件吗？如果删除将彻底不能找回';
	$("#edit-spfTradeContractWebimageRecord-dialog").alertmsg('confirm', _html, {
	    displayMode:'slide', 
		displayPosition:'topcenter',
        okName:'确定', 
        cancelName:'取消', 
        title:'提示信息',
        okCall : function(){
        	var url = 'spfTradeContractWebimage/del.do?id='+id;
        	var successCallBack = function(result){
        		$(_this).parent().remove();
        	}
        	myAjax(url,	"", true,successCallBack,null);
        },
        cancelCall : function(){
            
        }
	}); 
}
</script>
<div class="bjui-pageContent">
	
	<div style="height: 92%;position: relative;" id="contractFileForm_div">
		
	</div>

</div>
<div class="bjui-pageFooter">
	<ul>
		<li><button type="button" class="btn btn-red cancel" data-icon="remove">关闭</button></li>
	<auth:has funcId="spfTradeContractWebimage" action="/spfTradeContractWebimage/submit.do">
	<c:if test='${noupdate=="false"}'>
		<li><button type="button" class="btn btn-blue save" data-icon="save">提交</button></li>
	</c:if>
	</auth:has>
	</ul>
</div>
<div id="edit-spfTradeContractWebimageRecord-dialog" style="display: none;">
</div>